/*
 * @Description: 无
 * @Author: Sue
 * @Date: 2020-07-29 15:39:45
 * @LastEditors: Sue
 * @LastEditTime: 2020-08-03 13:28:51
 */
UE.registerUI(
  '135editor',
  function (editor, uiName) {
    if (!editor.options.use135) return
    var dialog = new UE.ui.Dialog({
      iframeUrl: '/ops/static/ue/135/135editor.html',
      cssRules:
        'width:' +
        parseInt(document.body.clientWidth * 0.9) +
        'px;height:' +
        (window.innerHeight - 50) +
        'px;',
      editor: editor,
      name: uiName,
      title: '135编辑器'
    })
    dialog.fullscreen = false
    dialog.draggable = false
    var btn = new UE.ui.Button({
      name: 'btn-dialog-' + uiName,
      className: 'edui-for-135editor',
      title: '135编辑器',
      onclick: function () {
        dialog.render()
        dialog.open()
      }
    })
    editor.addListener('selectionchange', function (type, causeByUi, uiReady) {
      var state = editor.queryCommandState(uiName)
      if (state == -1) {
        btn.setDisabled(true)
        btn.setChecked(false)
      } else {
        if (!uiReady) {
          btn.setDisabled(false)
          btn.setChecked(state)
        }
      }
    })
    return btn
  },
  undefined
)
